Security News
npm Updates Search Experience with New Objective Sorting Options
npm has a revamped search experience with new, more transparent sorting options—Relevance, Downloads, Dependents, and Publish Date.
sortable-dnd
Advanced tools
A JS Library for Drag and Drop, supports Sortable and Draggable
HTML
<ul id="group">
<li>
<i class="drag">drag me</i>
<p>1</p>
</li>
<li>
<i class="drag">drag me</i>
<p>2</p>
</li>
<li>
<i class="drag">drag me</i>
<p>3</p>
</li>
</ul>
JavaScript
import Sortable from 'sortable-dnd'
var DND = new Sortable(
document.getElementById('group'),
{
chosenClass: 'chosen',
draggable: (e) => e.target.tagName === 'I' ? true : false, // use function
// draggable: 'i' // use tagName
// draggable: '.drag' // use class
// draggable: '#drag' // use id
dragging: (e) => {
return e.target
},
dragEnd: (old, new, changed) => {
...
}
}
)
The component you created will clear all state after destroyed
option | type | default | Description |
---|---|---|---|
disabled | Boolean | false | Disables the sortable if set to true |
draggable | String/Function | undefined | Specifies which items inside the element should be draggable, the function type must return a boolean |
dragging | Function | undefined | Specifies the drag element, which must return an HTMLElement, such as (e) => e.target |
dragEnd | Function | undefined | The callback function when the drag is completed, such as (old, new, changed) => {} |
ghostStyle | Object | {} | The style of the mask element when dragging |
ghostClass | String | '' | The class of the mask element when dragging |
chosenClass | String | {} | The class of the selected element when dragging |
delay | Number | 0 | time in milliseconds to define when the sorting should start |
delayOnTouchOnly | Boolean | false | only delay if user is using touch |
animation | Number | 150 | Animation speed moving items when sorting |
ghostAnimation | Number | 0 | Ghost element animation delay before destroyed |
forceFallback | Boolean | false | true: ignore the HTML5 DnD behaviour and force the fallback to kick in |
stopPropagation | Boolean | false | The stopPropagation() method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases |
method | Description |
---|---|
destroy() | Manually clear all the state of the component, using this method the component will not be draggable |
FAQs
JS library for drag-and-drop lists, supports sortable and draggable
We found that sortable-dnd demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm has a revamped search experience with new, more transparent sorting options—Relevance, Downloads, Dependents, and Publish Date.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.